<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="业务单成本统计" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<script src="/js/QueryList.js"></script>
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doSearch(){
		var bbCode=document.getElementById("bb_code").value.trim();
		if(bbCode==""){
			ShowAlert('提示框','请输入业务单号',200,100);
		}else{
			var proTypeId=document.getElementById("pro_type_id").value;
			var proCode=encodeURIComponent(document.getElementById("pro_code").value.trim());
			var proName=encodeURIComponent(document.getElementById("pro_name").value.trim());
			
			window.location="/storehouse/OutCost.ihtm?bb_code="+bbCode+"&pro_type_id="+proTypeId+"&pro_code="+proCode+"&pro_name="+proName;
		}
	}
	function selectBusinessBill(){
		var url="/make/BusinessBillListForSelect.ihtm";
		ShowIframe("选择业务单",url,900,500,"selectBusinessBillCallBack()",1024,600);
	}
	function selectBusinessBillCallBack(){
		if(popRetVal!=null){
			document.getElementById("bb_code").value=popRetVal[1];
		}
	}
	function getSearchCondition(){
		var bbCode="${bbCode}";
		var proTypeId="${proTypeId}";
		var proCode="<c:out value="${proCode}" />";
		var proName="<c:out value="${proName}" />";
		var str="bb_code="+bbCode+"&pro_type_id="+proTypeId+"&pro_code="+proCode+"&pro_name="+proName;
		return str;
	}
	
	function doCancel(){
		window.close();
	}
	function doInit(){
		Window_Onload();
	}
	function checkKey(){
		if(window.event.keyCode==13){
			doSearch();
		}
	}
	function doPrint(){
		var str=getSearchCondition();
		showWin(1024,600,"/storehouse/OutCost.ihtm?content_type=PRINT&"+str);
	}
	function doDownload(){
		var str=getSearchCondition();
		window.location="/storehouse/OutCost.ihtm?content_type=EXCEL&"+str;
	}
</script>
</head>
<body oncontextmenu="return false" onLoad="doInit();" class="sheet" style="text-align:center;">
<div class="sheet-main" style="width:980px;text-align:left;margin:auto;">
  <div class="sheet-top">
    <div class="content">
      <h2>业务单成本统计</h2>
      <p>统计业务单消耗的材料成本</p>
    </div>
  </div>
  <div class="sheet-list">
    <div class="search-business">
      <div class="content">
        <table width="100%">
          <tbody>
            <tr>
              <td align="right">
				<input type="text" class="TextBox readonly" readonly="true" id="bb_code" name="bb_code" onKeyUp="checkKey();" style="width:80px" value="<c:out value="${bbCode}" />">
				<input type="button" class="buttom" value="选择业务单" onClick="selectBusinessBill();">
				<select name='pro_type_id' id='pro_type_id'>
					<option value="">==请选择材料类别==</option>
	  				<commonTag:createSelectTree list="${productTypeList}" emptyOption="0" defaultValue="${proTypeId}" />
	  			</select>
	  			材料编号：<input type="text" class="TextBox" id="pro_code" name="pro_code" onKeyUp="checkKey();" style="width:68px" value="<c:out value="${proCode}" />">
				品名规格：<input type="text" class="TextBox" id="pro_name" name="pro_name" onKeyUp="checkKey();" style="width:68px" value="<c:out value="${proName}" />">
				<div class="blank12"></div>
	              <div align="right">
				  <input type="button" class="buttom search-but" value=" 查 询" onClick="doSearch();">  
			      <c:if test="${list!=null}">
				    <input type="button" class="buttom  search-print" value=" 打 印" onClick="doPrint();">
				    <input type="button" class="buttom search-out" value=" 导 出 " onClick="doDownload();" <c:if test="${currentUser.user.userType!=1 && fn:indexOf(currentUser.privs,';NO_EXPO;')!=-1}">disabled="true"</c:if>>
			      </c:if>
			    </div>
			  </td>
            </tr>    
            </tbody>      
        </table>      	 
      </div>
   			
	  <c:if test="${list!=null}">
	  <c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';NO_TOTA;')==-1}">
      <div class="cue-info">
		<span>汇总金额：${totalCost}元</span>
      </div> 
      </c:if>
	  <div class="table-list">
        <table width="100%">
          <tr>
					<th  width="12%">单号</th>
					<th  width="9%">日期</th>
					<th  width="12%">供/需方</th>
					<th  width="5%">出/入</th>
					<th  width="10%">材料编号</th>
					<th  width="17%">品名规格</th>
					<th  width="5%">单位</th>
					<th  width="6%">数量</th>
					<th  width="6%">单价</th>
					<th  width="6%">金额</th>
					<th  width="12%">业务单号</th>
				</tr>
				<c:if test="${fn:length(list)==0}">
				<tr>
					<td colspan="11">没有出入库数据</td>
				</tr>
				</c:if>
				<c:forEach var="item" items="${list}" varStatus="i">
					<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
					<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
					<tr class="${trClass}" index="${i.index+1}" style='cursor:pointer;' onmouseout='javascript:mouseout(this)' onmouseover='javascript:mouseover(this)'>
						<td>${item.billCode}</td>
						<td><fmt:formatDate value="${item.billDate}" pattern="yyyy-MM-dd"/></td>
						<td>${item.otherName}</td>
						<td>
							<c:if test="${item.billType=='IN'}">入</c:if>
							<c:if test="${item.billType=='OUT'}">出</c:if>
						</td>
						<td>${item.productCode}</td>
						<td>${item.productName}</td>
						<td>${item.productUnit}</td>
						<td><commonTag:parseBigDecimal source="${item.amount}" /></td>
						<td><commonTag:parseBigDecimal source="${item.unitPrice}" /></td>
						<td><commonTag:parseBigDecimal source="${item.cost}" /></td>
						<td>${item.bbCode}</td>
					</tr>
				</c:forEach>
			</table>
     </div>
	 </c:if>
 </div>
</div>
</body>
</html>